package com.bjfu.gmms.servlet.departmentHeadServlet;

import com.bjfu.gmms.model.User;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/departmentHeadDashboardServlet")
public class DepartmentHeadDashboardServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取当前session中的用户信息
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");

        int collegeId = user.getUser_id();
        session.setAttribute("collegeId", collegeId);

        // 将请求转发到departmentHeadDashboard.jsp
        request.getRequestDispatcher("/WEB-INF/department_head_view/departmentHeadDashboard.jsp").forward(request, response);
    }
}
